package ceshi;

 class SelfPrivateNum {
    private int num =0;
    public  void addI(String username) {
		try {
			if (username.equals("a")) {
				num = 100;
				System.out.println("a set over!");
				Thread.sleep(2000);
			} else {
				num = 200;
				System.out.println("b set over!");
			}
			System.out.println(username + " num=" + num);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
 
 class ThreadNum extends Thread {

		private SelfPrivateNum numRef;

		public ThreadNum(SelfPrivateNum numRef) {
			super();
			this.numRef = numRef;
		}

	}

 
public class RunUnsafe {

	public static void main(String[] args) {

		SelfPrivateNum numRef = new SelfPrivateNum();

		new ThreadNum(numRef){
			public void run() {
				super.run();
				numRef.addI("a");
			}
		}.start();
		new ThreadNum(numRef){
			public void run() {
				super.run();
				numRef.addI("b");
			}
		}.start();


	}

}
